#pragma once
#include<iostream>
using namespace std;
#include"RBTree.h"
namespace yh {
	template<class K>
	class set {
		struct SetKeyOfT {
			const K& operator()(const K& key) {
				return key;
			}
		};
		//typedef RBTreeNode<K> Node;
	public:
		typedef typename RBTree<K, const K, SetKeyOfT>::iterator iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::const_iterator const_iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::reverse_iterator reverse_iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::const_reverse_iterator const_reverse_iterator;
		iterator begin() {
			return _t.begin();
		}
		iterator end() {
			return _t.end();
		}
		const_iterator cbegin() {
			return _t.cbegin();
		}
		const_iterator cend() {
			return _t.cend();
		}
		reverse_iterator rbegin() {
			return _t.rbegin();
		}
		reverse_iterator rend() {
			return _t.rend();
		}
		const_reverse_iterator crbegin() {
			return _t.crbegin();
		}
		const_reverse_iterator crend() {
			return _t.crend();
		}
		pair<iterator, bool> insert(const K& key) {
			return _t.insert(key);
		}

		iterator find(const K& key) {
			return _t.Find(key);
		}

	private:
		RBTree<K, const K, SetKeyOfT> _t;
	};


	void test_set1()
	{
		set<int> s;
		int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
		for (auto e : a)
		{
			s.insert(e);
		}
		set<int>::const_reverse_iterator it = s.crbegin();
		while (it != s.crend())
		{
			//if(*it % 2 == 0)
			//*it += 100;

			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}
